#!/bin/bash
PREFIX=srcds/l4d2_versus
mkdir -p ${HOME}/backup
cp -Lrv ${HOME}/${PREFIX}/left4dead2/left4dead2/cfg ${HOME}/backup/
cp -Lrv ${HOME}/${PREFIX}/left4dead2/left4dead2/addons/sourcemod/plugins ${HOME}/backup/
cp -Lrv ${HOME}/${PREFIX}/left4dead2/left4dead2/addons/sourcemod/gamedata ${HOME}/backup/
cp -Lrv cfg/superversus.cfg ${HOME}/${PREFIX}/left4dead2/left4dead2/cfg/
cp -Lrv cfg/sourcemod/*.cfg ${HOME}/${PREFIX}/left4dead2/left4dead2/cfg/sourcemod/
cp -Lrv cfg/sourcemod/*.ini ${HOME}/${PREFIX}/left4dead2/left4dead2/cfg/sourcemo
cp -Lrv gamedata/*.txt ${HOME}/${PREFIX}/left4dead2/left4dead2/addons/sourcemod/gamedata/
#cp -Lrv addons/*.vpk ${HOME}/left4dead2/left4dead2/left4dead2/addons/
cp -Lrv include/* ${HOME}/${PREFIX}/left4dead2/left4dead2/addons/sourcemod/scripting/include/
cp -Lrv additional/* ${HOME}/${PREFIX}/left4dead2/left4dead2/addons/sourcemod/scripting/
if [[ $1 == "install" ]]
then
cd plugins
for i in $(ls . | grep -v build.sh | grep -v install.sh | grep -v compiled | grep -v "*.sp~")
do
    ./build.sh $i
    if test "$?" -eq 0
    then
	./install.sh $i
    else
	exit
    fi
done
fi
echo -e  "all is installed except server.cfg (don't have rcon password !)"
